<template>
  <div>
    <home-header></home-header>
    <home-serach :school="Alldata"></home-serach>
    <home-list
    :list="province"
    :schooltype="schooltype"
    @changebelong="handlebelongclick"
    @changetype='handletypeclick'
    @changespecil='handlespecilclick'
    >
    </home-list>
    <college-list :data="Alldata" :belong="belong" :type="type" :specil="specil" :flag="flag"></college-list>
  </div>
</template>

<script>
import HomeSerach from './components/HomeSerach'
import HomeHeader from './components/Header'
import HomeList from './components/List'
import CollegeList from './components/CollegeList'
import axios from 'axios'
export default {
  name: 'Home',
  components: {
    HomeHeader,
    HomeSerach,
    HomeList,
    CollegeList
  },
  data () {
    return {
      Alldata: [],
      province: [],
      schooltype: [],
      belong: '全部',
      type: '全部',
      specil: '全部',
      flag: '无'
    }
  },
  methods: {
    getHomeInfo () {
      axios.get(' http://127.0.0.1:5000/')
        .then(this.getHomeInfoSucc)
      axios.get(' http://127.0.0.1:5000/province')
        .then(this.getprovince)
      axios.get(' http://127.0.0.1:5000/schooltype')
        .then(this.getschooltype)
    },
    getHomeInfoSucc (res) {
      this.Alldata = res.data
    },
    getprovince (res) {
      this.province = res.data
    },
    getschooltype (res) {
      this.schooltype = res.data
    },
    handlebelongclick (belong) {
      this.belong = belong
      this.flag = belong
      console.log(this.belong)
    },
    handletypeclick (type) {
      this.type = type
      console.log(this.type)
    },
    handlespecilclick (specil) {
      this.specil = specil
      console.log(this.specil)
    }
  },
  mounted () {
    this.getHomeInfo()
  }
}
</script>

<style>

</style>
